use crate::dto;
use crate::mq;
use std::sync::Arc;

pub struct ClientManager {
    te_policy_group:
        Arc<mq::client::node::endpoint::traffic_steering_rule::te_policy_group::Client>,
    pub candidate_path: Arc<
        mq::client::node::endpoint::traffic_steering_rule::te_policy_group::candidate_path::Client,
    >,
}

impl ClientManager {
    pub fn new(client: Arc<mq::client::Client>) -> Self {
        ClientManager {
            te_policy_group: Arc::new(
                mq::client::node::endpoint::traffic_steering_rule::te_policy_group::Client::new(
                    client.clone(),
                ),
            ),
            candidate_path: Arc::new(
                mq::client::node::endpoint::traffic_steering_rule::te_policy_group::candidate_path::Client::new(
                    client.clone(),
                )
            )
        }
    }
    pub async fn publish_setup_event(
        &self,
        node_id: &str,
        payload: dto::event::endpoint::traffic_steering_rule::te_policy_group::SetupEventPayload,
    ) -> Result<(), anyhow::Error> {
        self.te_policy_group
            .publish_setup_event(node_id, payload)
            .await
    }

    pub async fn publish_delete_event(
        &self,
        node_id: &str,
        payload: dto::event::endpoint::traffic_steering_rule::te_policy_group::DeleteEventPayload,
    ) -> Result<(), anyhow::Error> {
        self.te_policy_group
            .publish_delete_event(node_id, payload)
            .await
    }
}
